package com.shortterm.imgserver.controller;

import com.shortterm.imgserver.common.R;
import com.shortterm.imgserver.utils.AliOSSUtils;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;

/**
 * @program: edge-detection
 * @author: Jieyao Lu
 * @description:
 * @create: 2024/7/8 20:24
 **/
@RestController
@RequestMapping("/img")
@Slf4j
public class ImgController {


    @Resource
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public R<String> upload(@RequestBody MultipartFile file) throws IOException {
        return R.success(aliOSSUtils.upload(file));
    }

}
